package com.ruoyi.project.rm.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.project.rm.mapper.TaskMapper;
import com.ruoyi.project.rm.pojo.DataResult;
import com.ruoyi.project.rm.pojo.Task;
import com.ruoyi.project.rm.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskServiceImpl implements TaskService {

    @Autowired
    private TaskMapper taskMapper;

    @Override
    public DataResult<Task> selTaskInfo(int n,String taskName, int page, int rows) {

        Page<Task> tasks = PageHelper.startPage(page, rows);

        List<Task> list= taskMapper.selTaskInfo(taskName,n);

        DataResult<Task> dataResult=new DataResult<>();
        dataResult.setRows(tasks.getResult());
        dataResult.setTotal(tasks.getTotal());
        return dataResult;
    }

    @Override
    public DataResult<Task> selShowTask(int n, String taskName, int page, int rows) {
        Page<Task> tasks = PageHelper.startPage(page, rows);

        List<Task> list= taskMapper.selShowTask(taskName,n);

        DataResult<Task> dataResult=new DataResult<>();
        dataResult.setRows(tasks.getResult());
        dataResult.setTotal(tasks.getTotal());
        return dataResult;
    }

    @Override
    public int upEndTask(int taskId) {
        return taskMapper.upEndTask(taskId);
    }

    @Override
    public int insAddEndTask(int taskId) {
        return taskMapper.insAddEndTask(taskId);
    }

    @Override
    public int upPassTask(int taskId) {
        return taskMapper.upPassTask(taskId);
    }

    @Override
    public int addTask(Task task) {
        return taskMapper.addTask(task);
    }
}
